Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add baseline-immutables plugin to enable incremental compilation for Immutables #1750

Merged
merged 2 commits into from
May 3, 2021

Conversation

pkoenig10
Copy link
Member

Before this PR

Most of our internal projects use the Immutables annotation processor to generate immutable value objects.

Unfortunately, the Immutables processor does not support incremental compilation by default. This means that even trivial changes to subprojects that use the Immutables processor trigger a full rebuild.

For more details, see https://g.p.b/foundry/multipass/pull/11849.

After this PR

Fortunately, Immutables has opt-in support for enabling incremental compilation. See immutables/immutables#804.

This PR adds the baseline-immutables plugin to enable incremental compilation for source sets using the Immutables processor.

In my testing, I haven't encountered any issues and it dramatically improves compilation times during incremental work, which is fairly typical in dev workflows.

@changelog-app
Copy link

changelog-app bot commented May 3, 2021

Generate changelog in changelog/@unreleased

Type

  • Feature
  • Improvement
  • Fix
  • Break
  • Deprecation
  • Manual task
  • Migration

Description

Adds the baseline-immutables plugin to enable incremental compilation for Immutables.

Check the box to generate changelog(s)

  • Generate changelog entry

@policy-bot policy-bot bot requested a review from CRogers May 3, 2021 16:22
@pkoenig10 pkoenig10 force-pushed the pkoenig10/immutables branch from 8b86a46 to 5ec992b Compare May 3, 2021 16:24
project.getPluginManager().withPlugin("java", unused -> {
project.afterEvaluate(proj -> {
proj.getConvention().getPlugin(JavaPluginConvention.class).getSourceSets().stream()
.filter(sourceSet -> hasImmutablesProcessor(project, sourceSet))
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is necessary to avoid compiler warnings about unrecognized annotation processor options.

warning: The following options were not recognized by any processor: '[immutables.gradle.incremental]'
error: warnings found and -Werror specified
1 error
1 warning

@carterkozak
Copy link
Contributor

Have you verified this internally?

@pkoenig10 pkoenig10 changed the title Add baseline-immutables plugin to enable incremental compilation for … Add baseline-immutables plugin to enable incremental compilation for Immutables May 3, 2021
@pkoenig10 pkoenig10 force-pushed the pkoenig10/immutables branch from 5ec992b to 7892a7b Compare May 3, 2021 16:25
@pkoenig10
Copy link
Member Author

Yes, see the internal PR link above.

I've also testing this locally and have not seen any unexpected behavior.

@pkoenig10
Copy link
Member Author

Ah sorry, you meant the plugin. Will verify that also.

@carterkozak
Copy link
Contributor

Yep, I just want to make sure the plugin works as intended before we ship it.

@pkoenig10
Copy link
Member Author

I've verified locally that this works as expected.

@bulldozer-bot bulldozer-bot bot merged commit d9e7cc9 into develop May 3, 2021
@bulldozer-bot bulldozer-bot bot deleted the pkoenig10/immutables branch May 3, 2021 17:43
@svc-autorelease
Copy link
Collaborator

Released 3.81.0

@Override
public void apply(Project project) {
project.getPluginManager().withPlugin("java", unused -> {
project.afterEvaluate(proj -> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for tracking down this immutables behaviour and building this plugin! I'm excited for the speedup it should give repos.

Just made a follow up PR to remove this use of afterEvaluate - it's technically deprecated (although I don't think Gradle will ever be able to remove it) and the proliferation of afterEvaluates has caused us issues in the past to do with the order they run in. Luckily, we can use some of the newer lazy APIs to avoid this: #1752

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah sorry, thanks for fixing this! Didn't know that afterEvaluate was deprecated. Wasn't sure when this should be applied so I just copied code from an existing plugin.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants